home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 576 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.9 KB

  1. Path: cstatd.cstat.co.za!not-for-mail
  2. From: vincer@iaccess.za (Vince Risi)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.edu,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: 5 Jan 1996 09:58:32 +0200
  6. Organization: Internet Africa public service
  7. Message-ID: <E/56wg2yqXwB083yn@iaccess.za>
  8. References: <30C40F77.53B5@swsbbs.com> <marnoldDJEvtJ.1Lx@netcom.com>
  9.  <6sp2wg2yqLwd083yn@iaccess.za> <4cbkr9$5h2@preeda.internex.net.au>
  10. NNTP-Posting-Host: minnie.iafrica.com
  11.  
  12. In article <4cbkr9$5h2@preeda.internex.net.au>,
  13. sultan@connexus.apana.org.au (Jon Hornstein) wrote:
  14. > In article <6sp2wg2yqLwd083yn@iaccess.za>, vincer@iaccess.za says...
  15. > >
  16. > >In article <ou91k2jozn.fsf@i486.mcneil.com>,
  17. > >sean@mcneil.com (Sean McNeil) wrote:
  18. > >
  19. > >This kind of code....
  20. > >
  21. > >>  /* if the branches are of the same kind... */
  22. > >>  Branch brFirst= abrBranches[ixbrFirst];
  23. > >>  Branch brSecond= abrBranches[ixbrSecond];
  24. > >>  if (G_brKind(brFirst) == G_brKind(brSecond) &&
  25. > >>     /* ...and the same destination... */
  26. > >>      G_brDest(brFirst) == G_brDest(brSecond))
  27. > >>      {
  28. > >>      /* do something useful with the parallel edges */
  29. > >>      ...
  30. > >
  31. > >written as
  32. > >
  33. > >  Branch Branch1 = Branches[First];
  34. > >  Branch Branch2 = Branches[Second];
  35. > >  // if the branches are of the same kind...
  36. > >  // ...and the same destination...
  37. > >  if (KindBranch(Branch1) == KindBranch(Branch2) &&
  38. > >      DestBranch(Branch1) == DestBranch(Branch2))
  39. > >  {
  40. > >    // do something useful with the parallel edges
  41. > >    ...
  42. > >  }
  43. > >
  44. > >is far more readable, with strong typing there would be warnings
  45. > >if things were used incorrectly.
  46. > >
  47. > >Vince
  48. > >=====
  49.  
  50. > My experience, in the spirit of hungarian notation, is that it gives
  51. > consistent clues to the type and declaration of a declared variables.
  52.  
  53. Which is also its main weakness. There are many types of integers and
  54. floats. Each has its own prefix and when it comes to porting code
  55. or writing portable code then these become a real pain in the butt.
  56.  
  57. > I've
  58. > developed a consistent naming convention which includes hungarian notation
  59. > prefixes and and then noun combinations and perhaps a postfix to declare all
  60. > my variables.
  61.  
  62. Exactly you have developed your own naming convention.
  63.  
  64. > These variables may be quite large but thats never been a
  65. > consideration when it comes to finding errors.
  66.  
  67. > Branch1 and Branches is too confusing as a token. The information content in
  68. > the name is quite small.
  69.  
  70. It is perfectly adequate. In English and I presume American Branches means
  71. a collection on more than one branch, and Branch1, Branch2 are equally as
  72. expressive. I have no idea if Branch1 is supposed to be FirstBranch and
  73. Branch2 is supposed to be NextBranch. I am not at all intimate with the
  74. algorithm, I was just supplying a reasonable facsimile of what was
  75. presented previously with HN.
  76.  
  77. > I inferred from the name that it has something to
  78. > do with a generic branch. I would not add a generic hungarian prefix to
  79. > infrequently used types as they may cause confusion with the standard set of
  80. > tokens as used to define type.
  81.  
  82. > For example Branch1 could become br1, but thus could infer a boolean real 1
  83. > nonsense! My preference would be FirstBranch with no hungarian prefix!
  84.  
  85. > So instead of
  86.  
  87. > Branch Branch1 = Branches[First];
  88. > Branch Branch2 = Branches[Second];
  89. >  ...
  90. >
  91. > I may name it
  92. >
  93. > BRANCH FirstBranch = aBranches[FIRST_E],
  94. >        NextBranch  = aBranches[SECOND_E];
  95. >
  96. > // if the branches are of the same kind...
  97. > // ...and the same destination...
  98. > if (SameBranchType(FirstBranch)        == SameBranchType(NextBranch) &&
  99. >     SameBranchDestination(FirstBranch) == SameBranchDestination(NextBranch))
  100. > {
  101. >     // do something useful with the parallel edges
  102. >     ...
  103. > }
  104. >
  105. >
  106.  
  107. Why capitalize BRANCH? Is this part of the same plot that defines int INT,
  108. long LONG, double DOUBLE, ...?
  109.  
  110. All in all, lets agree to disagree on coding style.
  111.  
  112. Vince
  113.